<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?php echo $options->storename; ?></title>
<link rel='stylesheet' href='<?php echo base_url(); ?>style/adminstyle.css' />
<script type="text/javascript" src="<?php echo base_url(); ?>js/jquery.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>js/ajax.js"></script>

<script type="text/javascript">

//select all/select none

$(document).ready(function() {
        
        //select all/select none visible
        $("#selecting").show();
        
        $("#selall a").click(function()
        { 
                $("input[@type=checkbox]").each(function()
                {
                        this.checked = 'yes'; //checked_status;
                });
                return false;
        });
        
        $("#selnone a").click(function()
        {  
                $("input[@type=checkbox]").each(function()
                {
                        this.checked = ''; //checked_status;
                });
                return false;
        });
     
        //Delete Category Ajax
        $("#category_message").hide();
        <?php if (is_array($categories)) { foreach ($categories as $category) { ?>
                $("#areyousure-<?php echo $category->catid; ?>").hide();
                $("#areyousure-<?php echo $category->catid; ?>").html("Delete? <a style='text-decoration: underline; cursor: pointer' id='yes-<?php echo $category->catid; ?>'>Yes</a> <a style='text-decoration: underline; cursor: pointer' id='no-<?php echo $category->catid; ?>'>No</a>");
                
        	$("#deletecat_<?php echo $category->catid; ?>").click(function() {
        		
        		$("#cat-item-<?php echo $category->catid; ?>").hide();
        		$("#areyousure-<?php echo $category->catid; ?>").fadeIn('slow');
                        $("#category_message").slideDown('slow');
                        return false;
        	});
                $("#yes-<?php echo $category->catid; ?>").click(function() {
                        $.ajax({
                                type: "POST",
                                url: "<?php echo site_url(); ?>/admin/category/ajax_deletecategory/",
                                data: "id=<?php echo $category->catid; ?>",
                                success: function(msg){
                                        $("#cat-item-<?php echo $category->catid; ?>").hide();
                                        $("#areyousure-<?php echo $category->catid; ?>").hide('slow');
                                        $("#category_message").slideUp('slow');
                        	}
                        });    
                });
                $("#no-<?php echo $category->catid; ?>").click(function() {
                        $("#areyousure-<?php echo $category->catid; ?>").hide();
                        $("#cat-item-<?php echo $category->catid; ?>").fadeIn('slow');
                        $("#category_message").slideUp('slow');
                });
             <?php }} ?>
             
        //Add Category Ajax
        $("#addcatform").hide();
        $("#addcatform").html("<input id='catname' name='catname' size='10'  />");
        $("#addcatform").css("margin-top", "-10px");
     
        $("#addcat").click(function() {
                $("#addcat").hide();
                $("#addcatform").fadeIn('slow');
                $("#addcatform input").focus();
                return false;
        });
        
        $("#addcatform input").keydown(function(e) {

                if (e.keyCode == 13) { //ENTER pressed
                        //submit the new category
                        $.ajax({
                                type: "POST",
                                url: "<?php echo site_url(); ?>/admin/category/ajax_addcategory/",
                                data: "catname="+$("#addcatform input").val(),
                                success: function(msg){
                                        $("#addcatform").hide();
                                        $("#addcatform input").val("");
                                        $("#addcat").fadeIn('slow');
                                        $("#addcatshere").append(msg);
                        	}
                        });    
                }
                if (e.keyCode == 27) { //ESCAPE pressed
                        //cancel
                        $("#addcatform").hide();
                        $("#addcatform input").val("");
                        $("#addcat").fadeIn('slow');
                        
                }
                
        });


});

</script>

</head>
<body><?php if (empty($location)) $location = ''; ?>
	<div id="header">
		<span class="busbylogo"><img src="<?php echo base_url(); ?>images/busbyhead.jpg" /></span>
		
		
		<span class="hello">
			<b><?php echo $options->storename; ?> ( <?php echo anchor("","Storefront &raquo;"); ?> )</b> | <?php echo anchor("admin/settings","Settings"); ?> | <?php echo anchor("admin/help","Help"); ?> | <?php echo anchor("admin/login/logout","Logout"); ?>		
		</span>
	<span class="gsearch">
			<form method="get" action="http://images.google.ca/images" target="_blank" name="searchform" id="googlesearchform">
				<input type="text" name="q" id="s" value="" size="25" />
				<input name=btnG type=submit value="Google Image Search">
			<!-- ul>
			<li><a href="advanced_search.php">Show search options</a></li>
			<li><a href="">Create a category</a></li>
			</ul -->
			</form>
		</span>
	</div>
	
<div id="sidebar">
	<br />
		<ul class="upperleft">
			<li <?= ($location == 'add_item' ? 'class="current"' : 'class="post"') ?>><a href="<?=base_url()?>index.php/admin/add_item" title="List an Item">List an Item</a></li>
			<li <?= ($location == 'add_page' ? 'class="current"' : 'class="post"') ?>><a href="" title="Create a Page">Create a Page</a></li>
			
			
			<li <?= ($location == 'products' ? 'class="current"' : 'class=""') ?>><a href="<?php echo base_url(); ?>index.php/admin/products" title="Inventory ( <?=$numitems?> )">Inventory ( <?=$numitems?> )</a></li>
			<li <?= ($location == 'pages' ? 'class="current"' : 'class=""') ?>><a href="<?=base_url()?>index.php/admin/pages" title="Pages ( <?php echo $numpages; ?> )">Pages ( <?php echo $numpages; ?> )</a></li>
			<!--li class=""><a href="">Uploads</a></li -->
		</ul>

		<ul class="categories">
			<li class="title"><a href="<?=base_url()?>index.php/admin/category" style="text-decoration: none; color: white">Categories</a></li>
				<?php if (is_array($categories)) { foreach ($categories as $category) { ?>
				<li id="cat-item-<?php echo $category->catid; ?>">
					<a href="<?php echo base_url(); ?>index.php/admin/category/delete/<?php echo $category->catid; ?>"
						onclick="return false"
						style="color: red"
						title="Delete Category"
						id="deletecat_<?php echo $category->catid; ?>">x</a>
					<?php echo anchor("category/" . $category->catname,$category->catname); ?>
				</li>
                                <li id="areyousure-<?php echo $category->catid; ?>">
                                </li>
				<?php }} ?><span id="addcatshere"></span>
			<li class="edit"><a href="<?php echo base_url(); ?>index.php/admin/category/add" id="addcat" onclick="return false" title="Add Category">Add Category</a></li>
                        <li id="addcatform"></li>
                        
		</ul>
                <div id="category_message">Deleting a category does not delete the products associated with that category.</div>

</div>
	<div id="site">
	

	
	<div id="right">
		

